package com.data.center.config;

import com.data.center.service.RegionDivisionRelationService;
import com.data.center.util.AdminDivisionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Method;

/**
 * @descripition:行政区域编码工具类调用的区域查询方法配置类
 * */
@Configuration
@Slf4j
public class AdminDivisionUtilsConfig {

    @Autowired
    RegionDivisionRelationService regionDivisionRelationService;

    @Bean
    public AdminDivisionUtils AdminDivisionUtils() throws ClassNotFoundException, NoSuchMethodException {

        log.info("注册AdminDivisionUtils---------");
        Class c = Class.forName("com.data.center.service.impl.RegionDivisionRelationServiceImpl");
        Object obj = regionDivisionRelationService;
        Method method = c.getMethod("findByDivisionCode", String.class);
        log.info("注册AdminDivisionUtils完成");

        return new AdminDivisionUtils(c, obj, method);
    }

}
